package com.ibm.cloud.banking.customer.components;

import com.ibm.cloud.banking.customer.entity.CustomerCertificate;
import com.ibm.cloud.banking.customer.repository.ICustomerCertificateMapper;
import com.ibm.cloud.banking.facade.customer.dto.CustomerCertificateDTO;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CustomerCertificateBasisComponent {

    @Autowired
    ICustomerCertificateMapper customerCertificateMapper;

    public CustomerCertificate getCustomerCertificate(String idType, String idNo, String name){
        return customerCertificateMapper.selectByUnionKeys(idType,idNo,name);
    }

    public int saveCustomerCertificate(CustomerCertificate customerCertificate){
        return customerCertificateMapper.insertSelective(customerCertificate);
    }

    public Boolean deleteCustomerCertificate(CustomerCertificateDTO certificateDTO){
        return customerCertificateMapper.deleteByUnionKeys(certificateDTO.getIdNo(), certificateDTO.getIdType(), certificateDTO.getName());
    }
}
